﻿using STF.Blog.Common;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace STF.Blog.Model
{
    public class Blog:BaseEntity
    {
        [Required(ErrorMessage = "{0}不能为空")]
        [StringLength(255), Column(TypeName = "nvarchar(255)")]
        [Display(Name = "博客标题")]
        public string Title { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Column(TypeName = "text")]
        [Display(Name = "文章内容")]
        public string Content { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Column(TypeName = "date")]
        [Display(Name = "发布日期")]
        public DateTime PublishTime { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "状态码")]
        public StateCode StateCode { get; set; } = 0;

        [Display(Name ="点赞")]
        public int Like { get; set; }

        [Display(Name ="踩")]
        public int Trample { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "文章类型外键")]
        [ForeignKey(nameof(ArticleCateGory))]
        public int TypeId { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "发布形式外键")]
        [ForeignKey(nameof(ReleaseForm))]
        public int FbxsId { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "等级编号")]
        public int LevelId { get; set; } = -1;

        [Display(Name = "封面")]
        public int CoverId { get; set; }

        [ForeignKey(nameof(Users))]
        public int Uid { get; set; }

        public Users Users { get; set; }
        public ArticleCateGory ArticleCateGory { get; set; }
        public ReleaseForm ReleaseForm { get; set; }
    }
}
